/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.bc.RubroFacadeLocal;
import org.cip.esymons.general.be.Rubro;

/**
 *
 * @author christian
 */
public class RubroDelegate {

    private RubroFacadeLocal local;

    public RubroDelegate() {
        local=lookupRubroFacade();
    }

    public List<Rubro> listarTodosRubros(){
        return local.findAll();
    }

    public Rubro buscarUnRubro(Integer cod){
        return local.find(cod);
    }

    private RubroFacadeLocal lookupRubroFacade() {
        try {
            Context c = new InitialContext();
            return (RubroFacadeLocal) c.lookup("java:comp/env/RubroFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
